package com.itzhoun.controller;

import com.itzhoun.service.ImportService;
import com.itzhoun.vo.UserVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author 周楠
 * @Date 2022/07/14/下午 9:19
 */
@Slf4j
@RestController
@Tag(name = "导入导出")
public class ImportController {

    @Resource
    private ImportService importService;

    @Operation(summary = "导入")
    @PostMapping("/import")
    public Boolean importExcel(@RequestPart MultipartFile file){
        return importService.importFile(file);
    }

    @Operation(summary = "导出")
    @GetMapping("/export")
    public void exportData(HttpServletResponse response){
        importService.exportFile(response);
    }

    @Operation(summary = "查询")
    @GetMapping("/userList")
    public List<UserVO> userVOList(){
        return importService.userList();
    }
}
